<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>节流</title>
</head>
<body>
  <input type="text" class="input">
  <span>节流</span>
  <script>
    var inp = document.querySelector(".input");
    function throttle(func,delay){
      let vaild = true;
      return function(){
        if(!vaild){
          console.log('冷却')
         return false
        }
        vaild = false;
        let _this = this
        setTimeout(function(){
          func.apply(_this);
          vaild = true;
        },delay)
      }
    }
    inp.oninput = throttle(function(){
      console.log(this.value)
    },1000)
  </script>
</body>
</html>